﻿using _05.状态模式.Entities;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace _05.状态模式
{
    /// <summary>
    /// EF上下文
    /// </summary>
    public class DbSession : DbContext
    {
        protected DbSession() : base("name=State") { }

        public static DbContext CreateInstance()
        {
            DbContext dbContext = CallContext.GetData(typeof(DbSession).Name) as DbContext;
            if (dbContext == null)
            {
                dbContext = new DbSession();
                CallContext.SetData(typeof(DbSession).Name, dbContext);
            }
            return dbContext;
        }

        public DbSet<Project> Projects { get; set; }
    }
}
